const mongoose = require('mongoose')
const bcrypt = require('bcrypt')

const AdminUserSchema = new mongoose.Schema({
  username: { type: String, unique: true, required: true },
  password: {
    type: String,
    required: true,
    select: false,
    set(value) {
      return bcrypt.hashSync(value, 10)
    }
  },
  role: { type: Number, default: 1 }
})

const AdminUser = mongoose.model('AdminUser', AdminUserSchema, 'AdminUser')

module.exports = AdminUser
